package cn.itsource.basic.controller;

import cn.itsource.basic.service.ILoginService;
import cn.itsource.basic.util.AjaxResult;
import cn.itsource.org.domain.dto.WeChatBinderDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    /**
     * 账号密码登录
     * @return
     */
    @PostMapping("/account")
    public AjaxResult accountLogin(@RequestBody HashMap<String,Object> map){
        return loginService.accountLogin(map);
    }


    /**
     * 微信登录接口
     * @param map
     * @return
     */
    @PostMapping("/wechat")
    public AjaxResult wechatLogin(@RequestBody HashMap<String,String> map){
        return loginService.wechatLogin(map);
    }

    /**
     * 微信绑定接口
     */
    @PostMapping("/binder")
    public AjaxResult binder(@RequestBody WeChatBinderDto dto){
        return loginService.binder(dto);
    }
}
